home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
clang
/
c_course.zip
/
READGOOD.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-12-30
|
656b
|
25 lines
/* READGOOD.C fscanf() do/while but EOF test inside loop */
/* Notice that fscanf like fget has a c= in front of it. So the whole
fscanf function takes on the value of all characters in a stream while
it fills up the array identified in the third parameter. */
#include "stdio.h"
main()
{
FILE *fp1;
char oneword[100];
int c;
fp1 = fopen("TENLINES.TXT","r");
do {
c = fscanf(fp1,"%s",oneword); /* got one word from the file */
if (c != EOF)
printf("%s\n",oneword); /* display it on the monitor */
} while (c != EOF); /* repeat until EOF */
fclose(fp1);
}